//
// Created by 32513 on 25-2-11.
//

#include "chassis.h"

#include <tim.h>

#include "main.h"

/*Motor_Config_Here*/
static motor_t chassismotor[MOTOR_NUM] =
{
    {
        &htim3,
        GM310_RATIO
    },
    {
        &htim4,
        GM310_RATIO
    }
};






Motor_Error Motor_Init(motor_config_t *motor_config)
{
    for( int i = 0; i < MOTOR_NUM; i++)
    {

    }
}

void Get_Motor_Measure(motor_t * *motor_group)
{
    for(int i = 0; i < MOTOR_NUM; i++)
    {
        motor_group[i]->ecd_last = motor_group[i]->ecd;
        motor_group[i]->ecd = __HAL_TIM_GET_COUNTER(motor_group[i]->tim_handle);
        motor_group[i]->speed_rpm = (__HAL_TIM_IS_TIM_COUNTING_DOWN(motor_group[i]->tim_handle)*2 - 1) * (motor_group[i]->ecd - motor_group[i]->ecd_last);

    }
}

